<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>

<table id="table-8">
    <tbody>
    <tr>
        <td>商品名称: </td>
        <td>${detail.goodsName}</td>
    </tr>

    <tr>
        <td>商品描述: </td>
        <td>${detail.goodsDesc}</td>
    </tr>

    <tr>
        <td>秒杀价格: </td>
        <td>${detail.price}</td>
    </tr>

    <tr>
        <td>剩余库存</td>
        <td>${detail.leftAmount}</td>
    </tr>
    </tbody>
</table>

<c:choose>
    <c:when test="${start == 0 }">
        <b>秒杀未开始</b>
    </c:when>
    <c:when test="${start == 2 }">
        <b>秒杀已结束</b>
    </c:when>
    <c:otherwise>
        <a href="#" id="seckill_id" code="${detail.code}">去秒杀>></a>
    </c:otherwise>
</c:choose>

<script type="application/javascript">
    //收藏

    $("#seckill_id").click(function () {
        var code = $(this).attr("code");
        $.ajax({
            url: "/doSeckill/" + code,
            type:"POST",
            contentType:"application/json",
            dataType:"json",
            //data:JSON.stringify(sendData),
            success: function (result) {
                if(result.code == 0) {
                    window.location.href = "/order/" + result.data; //支付页面
                }
            }
        });
    });


</script>